1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module pango.PgCairo;
26 
27 private import cairo.Context;
28 private import cairo.FontOption;
29 private import glib.Str;
30 private import gobject.ObjectG;
31 private import pango.PgContext;
32 private import pango.PgFont;
33 private import pango.PgGlyphItem;
34 private import pango.PgGlyphString;
35 private import pango.PgLayout;
36 private import pango.PgLayoutLine;
37 private import pango.c.functions;
38 public  import pango.c.types;
39 
40 
41 /** */
42 public struct PgCairo
43 {
44 
45 	/**
46 	 * Retrieves any font rendering options previously set with
47 	 * [func@PangoCairo.context_set_font_options].
48 	 *
49 	 * This function does not report options that are derived from
50 	 * the target surface by [func@update_context].
51 	 *
52 	 * Params:
53 	 *     context = a `PangoContext`, from a pangocairo font map
54 	 *
55 	 * Returns: the font options previously set on the
56 	 *     context, or %NULL if no options have been set. This value is
57 	 *     owned by the context and must not be modified or freed.
58 	 *
59 	 * Since: 1.10
60 	 */
61 	public static FontOption contextGetFontOptions(PgContext context)
62 	{
63 		auto __p = pango_cairo_context_get_font_options((context is null) ? null : context.getPgContextStruct());
64 
65 		if(__p is null)
66 		{
67 			return null;
68 		}
69 
70 		return new FontOption(cast(cairo_font_options_t*) __p);
71 	}
72 
73 	/**
74 	 * Gets the resolution for the context.
75 	 *
76 	 * See [func@PangoCairo.context_set_resolution]
77 	 *
78 	 * Params:
79 	 *     context = a `PangoContext`, from a pangocairo font map
80 	 *
81 	 * Returns: the resolution in "dots per inch". A negative value will
82 	 *     be returned if no resolution has previously been set.
83 	 *
84 	 * Since: 1.10
85 	 */
86 	public static double contextGetResolution(PgContext context)
87 	{
88 		return pango_cairo_context_get_resolution((context is null) ? null : context.getPgContextStruct());
89 	}
90 
91 	/**
92 	 * Sets callback function for context to use for rendering attributes
93 	 * of type %PANGO_ATTR_SHAPE.
94 	 *
95 	 * See `PangoCairoShapeRendererFunc` for details.
96 	 *
97 	 * Retrieves callback function and associated user data for rendering
98 	 * attributes of type %PANGO_ATTR_SHAPE as set by
99 	 * [func@PangoCairo.context_set_shape_renderer], if any.
100 	 *
101 	 * Params:
102 	 *     context = a `PangoContext`, from a pangocairo font map
103 	 *     data = Pointer to `gpointer` to return user data
104 	 *
105 	 * Returns: the shape rendering callback
106 	 *     previously set on the context, or %NULL if no shape rendering callback
107 	 *     have been set.
108 	 *
109 	 * Since: 1.18
110 	 */
111 	public static PangoCairoShapeRendererFunc contextGetShapeRenderer(PgContext context, void** data)
112 	{
113 		return pango_cairo_context_get_shape_renderer((context is null) ? null : context.getPgContextStruct(), data);
114 	}
115 
116 	/**
117 	 * Sets the font options used when rendering text with this context.
118 	 *
119 	 * These options override any options that [func@update_context]
120 	 * derives from the target surface.
121 	 *
122 	 * Params:
123 	 *     context = a `PangoContext`, from a pangocairo font map
124 	 *     options = a `cairo_font_options_t`, or %NULL to unset
125 	 *         any previously set options. A copy is made.
126 	 *
127 	 * Since: 1.10
128 	 */
129 	public static void contextSetFontOptions(PgContext context, FontOption options)
130 	{
131 		pango_cairo_context_set_font_options((context is null) ? null : context.getPgContextStruct(), (options is null) ? null : options.getFontOptionStruct());
132 	}
133 
134 	/**
135 	 * Sets the resolution for the context.
136 	 *
137 	 * This is a scale factor between points specified in a `PangoFontDescription`
138 	 * and Cairo units. The default value is 96, meaning that a 10 point font will
139 	 * be 13 units high. (10 * 96. / 72. = 13.3).
140 	 *
141 	 * Params:
142 	 *     context = a `PangoContext`, from a pangocairo font map
143 	 *     dpi = the resolution in "dots per inch". (Physical inches aren't actually
144 	 *         involved; the terminology is conventional.) A 0 or negative value
145 	 *         means to use the resolution from the font map.
146 	 *
147 	 * Since: 1.10
148 	 */
149 	public static void contextSetResolution(PgContext context, double dpi)
150 	{
151 		pango_cairo_context_set_resolution((context is null) ? null : context.getPgContextStruct(), dpi);
152 	}
153 
154 	/**
155 	 * Sets callback function for context to use for rendering attributes
156 	 * of type %PANGO_ATTR_SHAPE.
157 	 *
158 	 * See `PangoCairoShapeRendererFunc` for details.
159 	 *
160 	 * Params:
161 	 *     context = a `PangoContext`, from a pangocairo font map
162 	 *     func = Callback function for rendering attributes of
163 	 *         type %PANGO_ATTR_SHAPE, or %NULL to disable shape rendering.
164 	 *     data = User data that will be passed to @func.
165 	 *     dnotify = Callback that will be called when the
166 	 *         context is freed to release @data
167 	 *
168 	 * Since: 1.18
169 	 */
170 	public static void contextSetShapeRenderer(PgContext context, PangoCairoShapeRendererFunc func, void* data, GDestroyNotify dnotify)
171 	{
172 		pango_cairo_context_set_shape_renderer((context is null) ? null : context.getPgContextStruct(), func, data, dnotify);
173 	}
174 
175 	/**
176 	 * Creates a context object set up to match the current transformation
177 	 * and target surface of the Cairo context.
178 	 *
179 	 * This context can then be
180 	 * used to create a layout using [ctor@Pango.Layout.new].
181 	 *
182 	 * This function is a convenience function that creates a context using
183 	 * the default font map, then updates it to @cr. If you just need to
184 	 * create a layout for use with @cr and do not need to access `PangoContext`
185 	 * directly, you can use [func@create_layout] instead.
186 	 *
187 	 * Params:
188 	 *     cr = a Cairo context
189 	 *
190 	 * Returns: the newly created `PangoContext`
191 	 *
192 	 * Since: 1.22
193 	 */
194 	public static PgContext createContext(Context cr)
195 	{
196 		auto __p = pango_cairo_create_context((cr is null) ? null : cr.getContextStruct());
197 
198 		if(__p is null)
199 		{
200 			return null;
201 		}
202 
203 		return ObjectG.getDObject!(PgContext)(cast(PangoContext*) __p, true);
204 	}
205 
206 	/**
207 	 * Creates a layout object set up to match the current transformation
208 	 * and target surface of the Cairo context.
209 	 *
210 	 * This layout can then be used for text measurement with functions
211 	 * like [method@Pango.Layout.get_size] or drawing with functions like
212 	 * [func@show_layout]. If you change the transformation or target
213 	 * surface for @cr, you need to call [func@update_layout].
214 	 *
215 	 * This function is the most convenient way to use Cairo with Pango,
216 	 * however it is slightly inefficient since it creates a separate
217 	 * `PangoContext` object for each layout. This might matter in an
218 	 * application that was laying out large amounts of text.
219 	 *
220 	 * Params:
221 	 *     cr = a Cairo context
222 	 *
223 	 * Returns: the newly created `PangoLayout`
224 	 *
225 	 * Since: 1.10
226 	 */
227 	public static PgLayout createLayout(Context cr)
228 	{
229 		auto __p = pango_cairo_create_layout((cr is null) ? null : cr.getContextStruct());
230 
231 		if(__p is null)
232 		{
233 			return null;
234 		}
235 
236 		return ObjectG.getDObject!(PgLayout)(cast(PangoLayout*) __p, true);
237 	}
238 
239 	/**
240 	 * Add a squiggly line to the current path in the specified cairo context that
241 	 * approximately covers the given rectangle in the style of an underline used
242 	 * to indicate a spelling error.
243 	 *
244 	 * The width of the underline is rounded to an integer number of up/down
245 	 * segments and the resulting rectangle is centered in the original rectangle.
246 	 *
247 	 * Params:
248 	 *     cr = a Cairo context
249 	 *     x = The X coordinate of one corner of the rectangle
250 	 *     y = The Y coordinate of one corner of the rectangle
251 	 *     width = Non-negative width of the rectangle
252 	 *     height = Non-negative height of the rectangle
253 	 *
254 	 * Since: 1.14
255 	 */
256 	public static void errorUnderlinePath(Context cr, double x, double y, double width, double height)
257 	{
258 		pango_cairo_error_underline_path((cr is null) ? null : cr.getContextStruct(), x, y, width, height);
259 	}
260 
261 	/**
262 	 * Adds the glyphs in @glyphs to the current path in the specified
263 	 * cairo context.
264 	 *
265 	 * The origin of the glyphs (the left edge of the baseline)
266 	 * will be at the current point of the cairo context.
267 	 *
268 	 * Params:
269 	 *     cr = a Cairo context
270 	 *     font = a `PangoFont` from a `PangoCairoFontMap`
271 	 *     glyphs = a `PangoGlyphString`
272 	 *
273 	 * Since: 1.10
274 	 */
275 	public static void glyphStringPath(Context cr, PgFont font, PgGlyphString glyphs)
276 	{
277 		pango_cairo_glyph_string_path((cr is null) ? null : cr.getContextStruct(), (font is null) ? null : font.getPgFontStruct(), (glyphs is null) ? null : glyphs.getPgGlyphStringStruct());
278 	}
279 
280 	/**
281 	 * Adds the text in `PangoLayoutLine` to the current path in the
282 	 * specified cairo context.
283 	 *
284 	 * The origin of the glyphs (the left edge of the line) will be
285 	 * at the current point of the cairo context.
286 	 *
287 	 * Params:
288 	 *     cr = a Cairo context
289 	 *     line = a `PangoLayoutLine`
290 	 *
291 	 * Since: 1.10
292 	 */
293 	public static void layoutLinePath(Context cr, PgLayoutLine line)
294 	{
295 		pango_cairo_layout_line_path((cr is null) ? null : cr.getContextStruct(), (line is null) ? null : line.getPgLayoutLineStruct());
296 	}
297 
298 	/**
299 	 * Adds the text in a `PangoLayout` to the current path in the
300 	 * specified cairo context.
301 	 *
302 	 * The top-left corner of the `PangoLayout` will be at the
303 	 * current point of the cairo context.
304 	 *
305 	 * Params:
306 	 *     cr = a Cairo context
307 	 *     layout = a Pango layout
308 	 *
309 	 * Since: 1.10
310 	 */
311 	public static void layoutPath(Context cr, PgLayout layout)
312 	{
313 		pango_cairo_layout_path((cr is null) ? null : cr.getContextStruct(), (layout is null) ? null : layout.getPgLayoutStruct());
314 	}
315 
316 	/**
317 	 * Draw a squiggly line in the specified cairo context that approximately
318 	 * covers the given rectangle in the style of an underline used to indicate a
319 	 * spelling error.
320 	 *
321 	 * The width of the underline is rounded to an integer
322 	 * number of up/down segments and the resulting rectangle is centered in the
323 	 * original rectangle.
324 	 *
325 	 * Params:
326 	 *     cr = a Cairo context
327 	 *     x = The X coordinate of one corner of the rectangle
328 	 *     y = The Y coordinate of one corner of the rectangle
329 	 *     width = Non-negative width of the rectangle
330 	 *     height = Non-negative height of the rectangle
331 	 *
332 	 * Since: 1.14
333 	 */
334 	public static void showErrorUnderline(Context cr, double x, double y, double width, double height)
335 	{
336 		pango_cairo_show_error_underline((cr is null) ? null : cr.getContextStruct(), x, y, width, height);
337 	}
338 
339 	/**
340 	 * Draws the glyphs in @glyph_item in the specified cairo context,
341 	 *
342 	 * embedding the text associated with the glyphs in the output if the
343 	 * output format supports it (PDF for example), otherwise it acts
344 	 * similar to [func@show_glyph_string].
345 	 *
346 	 * The origin of the glyphs (the left edge of the baseline) will
347 	 * be drawn at the current point of the cairo context.
348 	 *
349 	 * Note that @text is the start of the text for layout, which is then
350 	 * indexed by `glyph_item->item->offset`.
351 	 *
352 	 * Params:
353 	 *     cr = a Cairo context
354 	 *     text = the UTF-8 text that @glyph_item refers to
355 	 *     glyphItem = a `PangoGlyphItem`
356 	 *
357 	 * Since: 1.22
358 	 */
359 	public static void showGlyphItem(Context cr, string text, PgGlyphItem glyphItem)
360 	{
361 		pango_cairo_show_glyph_item((cr is null) ? null : cr.getContextStruct(), Str.toStringz(text), (glyphItem is null) ? null : glyphItem.getPgGlyphItemStruct());
362 	}
363 
364 	/**
365 	 * Draws the glyphs in @glyphs in the specified cairo context.
366 	 *
367 	 * The origin of the glyphs (the left edge of the baseline) will
368 	 * be drawn at the current point of the cairo context.
369 	 *
370 	 * Params:
371 	 *     cr = a Cairo context
372 	 *     font = a `PangoFont` from a `PangoCairoFontMap`
373 	 *     glyphs = a `PangoGlyphString`
374 	 *
375 	 * Since: 1.10
376 	 */
377 	public static void showGlyphString(Context cr, PgFont font, PgGlyphString glyphs)
378 	{
379 		pango_cairo_show_glyph_string((cr is null) ? null : cr.getContextStruct(), (font is null) ? null : font.getPgFontStruct(), (glyphs is null) ? null : glyphs.getPgGlyphStringStruct());
380 	}
381 
382 	/**
383 	 * Draws a `PangoLayout` in the specified cairo context.
384 	 *
385 	 * The top-left corner of the `PangoLayout` will be drawn
386 	 * at the current point of the cairo context.
387 	 *
388 	 * Params:
389 	 *     cr = a Cairo context
390 	 *     layout = a Pango layout
391 	 *
392 	 * Since: 1.10
393 	 */
394 	public static void showLayout(Context cr, PgLayout layout)
395 	{
396 		pango_cairo_show_layout((cr is null) ? null : cr.getContextStruct(), (layout is null) ? null : layout.getPgLayoutStruct());
397 	}
398 
399 	/**
400 	 * Draws a `PangoLayoutLine` in the specified cairo context.
401 	 *
402 	 * The origin of the glyphs (the left edge of the line) will
403 	 * be drawn at the current point of the cairo context.
404 	 *
405 	 * Params:
406 	 *     cr = a Cairo context
407 	 *     line = a `PangoLayoutLine`
408 	 *
409 	 * Since: 1.10
410 	 */
411 	public static void showLayoutLine(Context cr, PgLayoutLine line)
412 	{
413 		pango_cairo_show_layout_line((cr is null) ? null : cr.getContextStruct(), (line is null) ? null : line.getPgLayoutLineStruct());
414 	}
415 
416 	/**
417 	 * Updates a `PangoContext` previously created for use with Cairo to
418 	 * match the current transformation and target surface of a Cairo
419 	 * context.
420 	 *
421 	 * If any layouts have been created for the context, it's necessary
422 	 * to call [method@Pango.Layout.context_changed] on those layouts.
423 	 *
424 	 * Params:
425 	 *     cr = a Cairo context
426 	 *     context = a `PangoContext`, from a pangocairo font map
427 	 *
428 	 * Since: 1.10
429 	 */
430 	public static void updateContext(Context cr, PgContext context)
431 	{
432 		pango_cairo_update_context((cr is null) ? null : cr.getContextStruct(), (context is null) ? null : context.getPgContextStruct());
433 	}
434 
435 	/**
436 	 * Updates the private `PangoContext` of a `PangoLayout` created with
437 	 * [func@create_layout] to match the current transformation and target
438 	 * surface of a Cairo context.
439 	 *
440 	 * Params:
441 	 *     cr = a Cairo context
442 	 *     layout = a `PangoLayout`, from [func@create_layout]
443 	 *
444 	 * Since: 1.10
445 	 */
446 	public static void updateLayout(Context cr, PgLayout layout)
447 	{
448 		pango_cairo_update_layout((cr is null) ? null : cr.getContextStruct(), (layout is null) ? null : layout.getPgLayoutStruct());
449 	}
450 }